package com.feign.demo.web;

import com.feign.demo.service.FeignTestForOneService;
import com.feign.demo.service.FeignTestForTwoService;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by CHUMI on 2018/1/2.
 */
@RestController
public class FeignTestController {
    private static final Logger LOG = Logger.getLogger(FeignTestController.class.getName());
    @Autowired
    FeignTestForOneService feignTestService;

    @Autowired
    FeignTestForTwoService feignTestForTwoService;
    @RequestMapping(value = "/feignHi",method = RequestMethod.GET)
    public String sayHi(@RequestParam String name){
        try {
            LOG.log(Level.INFO, "calling trace service-hi  ");
            String demoOne = feignTestService.sayHiFromClientOne(name);
            LOG.log(Level.INFO, demoOne);
            LOG.log(Level.INFO, "calling trace service-hi2  ");
            return feignTestForTwoService.sayHiFromClientOne(name);
        }finally {
            LOG.log(Level.INFO, "service-hi2    is over");
        }
    }

    @RequestMapping(value = "/feignHi2",method = RequestMethod.GET)
    public String sayHi2(@RequestParam String name){

        return feignTestForTwoService.sayHiFromClientOne(name);
    }
}
